#include "boss.h"
#include "config.h"

boss::boss()
{
    m_boss.load(":/picture/images/enemy3_n1.png");
    m_x=0;
    m_y=0;
    m_free=true;
    m_speed=BOSS_SPEED;
    m_Rect.setWidth(m_boss.width());
    m_Rect.setHeight(m_boss.height());
    m_Rect.moveTo(m_x,m_y);
}

void boss::updatePosition()
{
    if(m_free){return;}
    m_y+=m_speed;
    m_Rect.moveTo(m_x,m_y);
    if(m_y>=GAME_HEIGHT+m_Rect.height())
    {
        m_free=true;
    }
}

void boss::shoot()
{
    m_recorder++;
    if(m_recorder<ATTACK_INTERVAL){return;}
    m_recorder=0;
    for(int i=0;i<3;i++)
    {
        for(int j=0;j<ATTACK_NUM;j++)
        {
          if(m_attack[i][j].m_free)
          {
              m_attack[i][j].m_free=false;
              m_attack[i][j].m_x=m_x + m_Rect.width()*0.5-2;
              m_attack[i][j].m_y=m_y + 200;
              break;
          }
        }
    }
}
